/* The file is saved in UTF-8 codepage.
 * Check: «Stereotype», Section mark-§, Copyright-©, Alpha-α, Beta-β, Smile-☺
 */
package cz.pecinovsky.english.lootp._115_;

import cz.pecinovsky.english.lootp._000_.Run;

import cz.pecinovsky.english.lootp.manager.Mover;


import cz.pecinovsky.english.lootp.manager.CanvasManager_Envelope.               CanvasManager;

import cz.pecinovsky.english.lootp.utility.NamedColor;
import cz.pecinovsky.english.lootp.utility.IO;


// %I+ <120z
//import cz.pecinovsky.english.lootp._115_._116_Semafor_119.TrafficLight;
// %I-
import cz.pecinovsky.english.lootp._115_.TrafficLight_120_124.                   TrafficLight;



//import cz.pecinovsky.english.lootp._115_.TrafficLightTest_117_124.             TrafficLightTest;
////////////////////////////////////////////////////////////////////////////////
//%%+  +++++ End of ignored starting test - place for imports +++++

//%X+ xxxxx Start of the ovejumped text with declaration of the envelope xxxxx
/*******************************************************************************
 *<pre>
 * Previous:  No - this is a newly defined class
 * Following: No
 *
 * Project  016z_02_Tvary
 *   + Two constructors
 *
 *</pre>
 *
 * @author Rudolf PECINOVSKÝ
 * @version 6.03.2017 — 2010-11-08
 */
/*******************************************************************************
 *<pre>
 * Předchozí:   Není - toto_je_nově_definovaná_třída
 *              Ttt v projektu Ppp
 * Následující: Prozatím není
 *
 * Projekt  Ppp
 *   + Přidáno
 *   - Odebráno
 *   ~ Změněno
 *</pre>
 */
public class TrafficLightTest_117_124
{    private TrafficLightTest_117_124() {}   static
////////////////////////////////////////////////////////////////////////////////
//%X- ----- End of the ovejumped text with declaration of the envelope -----


/*******************************************************************************
 * Testovací třída {@code TrafficLightTest}  slouží ke komplexnímu otestování
 * třídy {@link TrafficLightTest}.
 *
 * @author Rudolf PECINOVSKÝ
 * @version 6.03.2017 — 2010-11-08
 */
public class TrafficLightTest extends junit.framework.TestCase
{
//%X+ <119
    private CanvasManager CM;
//%X-
    private TrafficLight trafficLight0;
    private TrafficLight trafficLightXY;
    private TrafficLight trafficLightXYB;
//%X+ <122
    private TrafficLight trafficLightXYP;
    private TrafficLight trafficLightXYPB;
//%X-



//== CONSTANT CLASS ATTRIBUTES =================================================
//== VARIABLE CLASS ATTRIBUTES =================================================
//== STATIC CONSTRUCTOR (CLASS INITIALIZER, STATIC INICITALIZING BLOCK) ========
//== CONSTANT INSTANCE ATTRIBUTES ==============================================
//== VARIABLE INSTANCE ATTRIBUTES ==============================================
//== CLASS GETTERS AND SETTERS =================================================
//== OTHER NON-PRIVATE CLASS METHODS ===========================================

//##############################################################################
//== CONSTUCTORS AND FACTORY METHODS ===========================================

    /***************************************************************************
     * Vytvoří test se zadaným názvem.
     *
     * @param name  Název konstruovaného testu
     */
    public TrafficLightTest(String name)
    {
        super(name);
    }



//== PREPARATION AND CLEANING THE FIXTURE ======================================

    /***************************************************************************
     * Inicializace předcházející spuštění každého testu a připravující tzv.
     * přípravek (fixture), což je sada objektů, s nimiž budou testy pracovat.
     */
    @Override
    protected void setUp()
    {
        trafficLight0   = new TrafficLight();
        trafficLightXY  = new TrafficLight(100,  50);
        trafficLightXYB = new TrafficLight(150, 100, NamedColor.BROWN);
//%X+ <122
        trafficLightXYP = new TrafficLight(75,  25, 25);
        trafficLightXYPB= new TrafficLight(200,   0, 100, NamedColor.BLUE);
//%X-
//%X+ <119

        CM = CanvasManager.getInstance();
        CM.add(trafficLight0);
        CM.add(trafficLightXY);
        CM.add(trafficLightXYB);
//%X-
//%X+ <122
        CM.add(trafficLightXYP);
        CM.add(trafficLightXYPB);
//%X-

        IO.inform("Traffic lights prepared");
    }


    /***************************************************************************
     * Úklid po testu - tato metoda se spustí po vykonání každého testu.
     */
    @Override
    protected void tearDown()
    {
    }


//== PRIVATE AND AUXILIARY CLASS METHODS =======================================
//== PRIVATE AND AUXILIARY INSTANCE METHODS ====================================
//%X+ <123

    /***************************************************************************
     * Vyzkouší změny pozice a velikosti zadaného trafficLightu
     */
    private void auxPositionSize(TrafficLight s)
    {
        final int ms = 500;
        s.setPosition(50, 0);
        IO.pause(ms);
        s.setModule(100);
        IO.pause(ms);
        s.setModule(25);
        IO.pause(ms);
        CM.remove(s);
        IO.pause(ms);
    }

//%X-
//%X+ <123


//%X-
//== EMBEDDED TYPES AND INNER CLASSES ==========================================
//== THE TESTS =================================================================
//
//     /***************************************************************************
//      *
//      */
//     public void testXXX()
//     {
//     }
//%X+ <118


    public void testCycle()
    {
        trafficLight0   .cycle();
        trafficLightXY  .cycle();
        trafficLightXYB .cycle();
//%X-
//%X+ <122
        trafficLightXYP .cycle();
        trafficLightXYPB.cycle();
//%X-
//%X+ <118
    }
//%X-
//%X+ <124

    public void testSmoothMovement()
    {
        Mover p = new Mover(10);
        p.moveTo(100, 150, trafficLight0);
        p.moveTo(150,   0, trafficLightXY);
        p.moveTo(100,   0, trafficLightXYB);
        p.moveTo(150, 150, trafficLightXYP);
        p.moveTo(  0,   0, trafficLightXYPB);
    }

//%X-
//%X+ <123

    public void testPositionSize()
    {
        auxPositionSize(trafficLight0);
        auxPositionSize(trafficLightXY);
        auxPositionSize(trafficLightXYB);
        auxPositionSize(trafficLightXYP);
        auxPositionSize(trafficLightXYPB);
    }

//%X-
//%X+   Metoda připravená k vložení do testovacích tříd
     /** */
     public void testFixture() {}
//%X-
}

//%%- ---- Start of the ovejumped text with closing of the envelope ----
////////////////////////////////////////////////////////////////////////////////
//== TESTING CLASSES AND METHODS ===============================================
//Není-li třída testovací, následující dvě metody se smažou


    /***************************************************************************
     * Třída, jejíž instance má na starosti úklid mezi jednotlivými testy,
     * který není možno zakomponovat do metody {@code tearDown()},
     * dokud nebudou studenti umět programovat.
     */
    private static class TearDown implements Run.ITD
    {
        /** {@inheritDoc} */
        @Override
        public void cleanUp()
        {
//            Canvas.clearCanvas();
//            CanvasManager.getInstance().removeAll();
        }
    }


    /***************************************************************************
     * Test method.
     */
    public static void test()
    {
        Run.tests(TrafficLightTest.class,
                new TearDown(),
//                "testFixture",
//                "testCycle",
//                "testPositionSize",
                "testSmoothMovement",
                "");
        System.exit(0);
    }
    /** @param args Parametry příkazového řádku - nepoužívané. */
    public static void main(String[] args)  {  test();  }
}
